//
//  PSNodeScore.h
//  PrefCore
//
//  Created by Sergey on 5/15/14.
//  Copyright (c) 2014 Play-on-smart. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "PSGame.h"

#define PS_SCORE_MASK ((uint16_t)0x0FFF)

#define PS_SCORE_COMPLETE ((uint16_t)0x1000)

typedef uint16_t PSPackedScore;

inline uint8_t PSScoreGet(PSPackedScore packed, PSPlayerId player) {
    return (uint8_t)((packed >> (player << 2)) & 0x0F);
}

inline PSPackedScore PSScoreIncrement(PSPackedScore packed, PSPlayerId player) {
    return (PSPackedScore)(packed + (1 << (player << 2)));
}

inline BOOL PSScoreIsComplete(PSPackedScore packed) {
    return (packed & PS_SCORE_COMPLETE) != 0;
}

extern NSString *PSScoreDescription(PSPackedScore packed);